home *** CD-ROM | disk | FTP | other *** search
- Path: user1.mnsinc.com!huang
- From: huang@mnsinc.com (Szu-Wen Huang)
- Newsgroups: comp.lang.c++,comp.lang.c,comp.os.msdos.programer,comp.os.ms-windows.programmer.misc
- Subject: Re: fastest code
- Followup-To: comp.lang.c++,comp.lang.c,comp.os.msdos.programer,comp.os.ms-windows.programmer.misc
- Date: 7 Apr 1996 22:35:48 GMT
- Organization: Monumental Network Systems
- Message-ID: <4k9g04$4ov@news1.mnsinc.com>
- References: <316112A2.7D37@public.sta.net.cn> <31611AC9.7DE1@wight.hursley.ibm.com> <3162c21a.6084138@204.248.25.97> <31641DE2.31D4@halcyon.com> <31658942.99299605@204.248.25.97>
- NNTP-Posting-Host: user1.mnsinc.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- William E. Kempf (srwillrd@novia.net) wrote:
-
- : Ok, my cutsy remark has confused several people, so I will explain.
- : In computer science, algorithms (and this will apply to the final
- : machine code generated by a compiler) are evaluated for speed in a
- : system independant way, through a formula known as Big-O notation. So
- : code is not said to be faster just because it is running on a faster
- : machine. The executable program may be faster, but the underlying
- : code may not be. All kinds of things can effect this, such as wether
- : or not the compiler moves variable declarations outside of loops, etc.
-
- Unfortunately, the big-O analysis of algorithms do not tell you of
- the algorithm's speed, rather, it shows the relationship between
- input size and execution time. An O(n^2) algorithm may run faster
- than an O(n) algorithm for all practical sizes of n.
-
- : The original question was looking for this kind of information (even
- : if the poster does not understand Big-O, which I don't know if he did
- : or not). He wants to know what compiler will best optimize the
- : machine language code generated for a specific OS and computer
- : architecture.
-
- Optimizations have little to do with time complexities as well. A
- compiler today is not likely to change an O(n^2) algorithm into an
- O(n) algorithm simply by optimizing the code, though an O(n) algorithm
- might be optimized into an O(1) algorithm if you're talking about a
- truly dumb programmer ;).
-